const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('edu_categories', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    title: {
      type: DataTypes.STRING(10),
      allowNull: false,
      comment: "分类名称"
    },
    parent_id: {
      type: DataTypes.CHAR(19),
      allowNull: false,
      defaultValue: "0",
      comment: "父ID,0为父元素"
    },
    level: {
      type: DataTypes.TINYINT,
      allowNull: false,
      defaultValue: 0,
      comment: "当前分类等级，默认为1级分类"
    },
    sort: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "排序字段"
    }
  }, {
    sequelize,
    tableName: 'edu_categories',
    timestamps: true,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
